package com.ruoyi.web.admin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.web.admin.domain.TdmBaoJianPin;
import com.ruoyi.web.admin.service.ITdmBaoJianPinService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * ID-08 保健品数据库Controller
 * 
 * @author ly
 * @date 2022-03-08
 */
@RestController
@RequestMapping("/admin/bao_jian_pin")
public class TdmBaoJianPinController extends BaseController
{
    @Autowired
    private ITdmBaoJianPinService tdmBaoJianPinService;

    /**
     * 查询ID-08 保健品数据库列表
     */
//    @PreAuthorize("@ss.hasPermi('admin:bao_jian_pin:list')")
    @GetMapping("/list")
    public TableDataInfo list(TdmBaoJianPin tdmBaoJianPin)
    {
        startPage();
        List<TdmBaoJianPin> list = tdmBaoJianPinService.selectTdmBaoJianPinList(tdmBaoJianPin);
        return getDataTable(list);
    }

    /**
     * 导出ID-08 保健品数据库列表
     */
//    @PreAuthorize("@ss.hasPermi('admin:bao_jian_pin:export')")
    @Log(title = "ID-08 保健品数据库", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TdmBaoJianPin tdmBaoJianPin)
    {
        List<TdmBaoJianPin> list = tdmBaoJianPinService.selectTdmBaoJianPinList(tdmBaoJianPin);
        ExcelUtil<TdmBaoJianPin> util = new ExcelUtil<TdmBaoJianPin>(TdmBaoJianPin.class);
        util.exportExcel(response, list, "ID-08 保健品数据库数据");
    }

    /**
     * 获取ID-08 保健品数据库详细信息
     */
//    @PreAuthorize("@ss.hasPermi('admin:bao_jian_pin:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tdmBaoJianPinService.selectTdmBaoJianPinById(id));
    }

    /**
     * 新增ID-08 保健品数据库
     */
//    @PreAuthorize("@ss.hasPermi('admin:bao_jian_pin:add')")
    @Log(title = "ID-08 保健品数据库", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TdmBaoJianPin tdmBaoJianPin)
    {
        return toAjax(tdmBaoJianPinService.insertTdmBaoJianPin(tdmBaoJianPin));
    }
    /**
     * 审核
     */
    @Log(title = "ID-08 保健品数据库")
    @PutMapping("/examine")
    public AjaxResult examine(@RequestBody TdmBaoJianPin tdmBaoJianPin)
    {
        return toAjax(tdmBaoJianPinService.updateTdmBaoJianPin(tdmBaoJianPin));
    }

    /**
     * 修改ID-08 保健品数据库
     */
//    @PreAuthorize("@ss.hasPermi('admin:bao_jian_pin:edit')")
    @Log(title = "ID-08 保健品数据库", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TdmBaoJianPin tdmBaoJianPin)
    {
        return toAjax(tdmBaoJianPinService.updateTdmBaoJianPin(tdmBaoJianPin));
    }

    /**
     * 删除ID-08 保健品数据库
     */
//    @PreAuthorize("@ss.hasPermi('admin:bao_jian_pin:remove')")
    @Log(title = "ID-08 保健品数据库", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tdmBaoJianPinService.deleteTdmBaoJianPinByIds(ids));
    }
}
